﻿using static _获取磁盘的剩余空间大小.Program;

namespace _获取磁盘的剩余空间大小
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string currentDirectory = Environment.CurrentDirectory;
            char driveLetter = currentDirectory[0];
            long freeSpace = GetFreeDiskSpace($"{driveLetter.ToString()}:");
            float surplusMemory = (float)(freeSpace / (1024.0 * 1024.0 * 1024.0));
            string msg = $"{driveLetter.ToString()}盘剩余空间: {surplusMemory.ToString("F2")} GB";
            Console.WriteLine(msg);
            ChapterInfo chapterInfo = GetChapterInfo(895, 100);
            List<WxQuestionSectionsOut> wxQuestionSectionsOuts = new List<WxQuestionSectionsOut>();
            if (chapterInfo != null)
            {
                foreach (var item in chapterInfo.Chapters)
                {
                    WxQuestionSectionsOut wxQuestionSectionsOut = new WxQuestionSectionsOut()
                    {
                        Section = item.ChapterNumber,
                        QuestionCount = item.ItemCount,
                    };
                    wxQuestionSectionsOuts.Add(wxQuestionSectionsOut);
                }
               
            }
            else
            {
                
            }
        }
        public static long GetFreeDiskSpace(string driveName)
        {
            DriveInfo drive = new DriveInfo(driveName);
            return drive.AvailableFreeSpace;
        }
        public class ChapterInfo
        {
            public List<(int ChapterNumber, int ItemCount)> Chapters { get; set; }
        }
        public static ChapterInfo GetChapterInfo(int totalItems, int maxItemsPerChapter)
        {
            ChapterInfo chapterInfo = new ChapterInfo();
            chapterInfo.Chapters = new List<(int, int)>();

            int currentChapter = 1;
            int remainingItems = totalItems;

            while (remainingItems > 0)
            {
                int itemsInCurrentChapter = Math.Min(maxItemsPerChapter, remainingItems);
                chapterInfo.Chapters.Add((currentChapter, itemsInCurrentChapter));
                remainingItems -= itemsInCurrentChapter;
                currentChapter++;
            }

            return chapterInfo;
        }
     

    }
    public class WxQuestionSectionsOut
    {
        /// <summary>
        /// 章节
        /// </summary>
        public int Section { get; set; }
        /// <summary>
        /// 题目数量
        /// </summary>
        public int QuestionCount { get; set; }
    }

}
